﻿
$.MGJ.DiamondEdition = [];
(function () {
    var _this = $.MGJ.DiamondEdition;
    $.extend($.MGJ.DiamondEdition, {

        //导航蒙层
        Dialog_NavEditObj: null,
        Dialog_NavEdit: function (obj) {

            var navId = $(obj ).attr("data-navId");

            this.Dialog_NavEditObj = $.L.dialog({
                url: ACTION_URL("NavEdit", "OriginsMaterial")+"?navId="+navId,
                title: "导航",
                width: 400,
                height: "auto",
                buttons: {
                    "button_save": {
                        type: 'primary',
                        text: '保存',
                        click: function () {
                            $.MGJ.DiamondEdition.Ajax_NavSave();
                            _this.Dialog_NavEditObj.close();
                        }
                    },
                    "button_cancel": {
                        type: 'default',
                        text: '取消',
                        click: 'MODALMISS'
                    }
                }
            });
        },
        //标题样式
        Dialog_SelectTitleStyleObj: null,
        Dialog_SelectTitleStyle: function () {
            this.Dialog_SelectTitleStyleObj = $.L.dialog({
                url: ACTION_URL("SelectTitleStyle", "OriginsMaterial"),
                title: "选择样式",
                width: 400,
                height: "auto",
                buttons: {
                    "button_save": {
                        type: 'primary',
                        text: '保存',
                        click: function () {
                           
                            var index = $("[data-se='true']").attr("data-index");
                            $("#TitleStyle1").val(index)
                            rebackIndex(inputName, index);
                            _this.Dialog_SelectTitleStyleObj.close();
                        }
                    },
                    "button_cancel": {
                        type: 'default',
                        text: '取消',
                        click: 'MODALMISS'
                    }
                }
            });
        },
        //模块选择
        Dialog_SelectModuleListObj: null,
        Dialog_SelectModuleList: function () {
            var materialId = $("#materialId").val();

            this.Dialog_SelectModuleListObj = $.L.dialog({
                url: ACTION_URL("SelectModuleList", "OriginsMaterial") + "?materialId=" + materialId,
                title: "模块选择",
                width: 800,
                height: "auto",
                //buttons: {
                //    "button_save": {
                //        type: 'primary',
                //        text: '保存',
                //        click: function () {
                //            $.L.msgError(1)
                //        }
                //    },
                //    "button_cancel": {
                //        type: 'default',
                //        text: '取消',
                //        click: 'MODALMISS'
                //    }
                //}
            });
        },
        //素材选择
        Dialog_SelectMaterialListObj: null,
        Dialog_SelectMaterialList: function () {
            this.Dialog_SelectMaterialListObj = $.L.dialog({
                url: ACTION_URL("SelectMaterialList", "OriginsMaterial"),
                title: "素材选择",
                width: 800,
                height: "auto",
                //buttons: {
                //    "button_save": {
                //        type: 'primary',
                //        text: '保存',
                //        click: function () {
                //            $.L.msgError(1)
                //        }
                //    },
                //    "button_cancel": {
                //        type: 'default',
                //        text: '取消',
                //        click: 'MODALMISS'
                //    }
                //}
            });
        },

        //认证库选择
        Dialog_SelectAuthListObj: null,
        Dialog_SelectAuthList: function () {
            this.Dialog_SelectAuthListObj = $.L.dialog({
                url: ACTION_URL("SelectAuthList", "Auth"),
                title: "认证库选择",
                width: 550,
                height: 500,
                //buttons: {
                //    "button_save": {
                //        type: 'primary',
                //        text: '保存',
                //        click: function () {
                //            $.L.msgError(1)
                //        }
                //    },
                //    "button_cancel": {
                //        type: 'default',
                //        text: '取消',
                //        click: 'MODALMISS'
                //    }
                //}
            });
        },

        //修改认证库
        
        Dialog_EditAuthListObj: null,
        Dialog_EditAuthList: function () {
            //console.log($("#AuthId").val())
            if ($("#AuthId").val() != "") {
                this.Dialog_EditAuthListObj = $.L.dialog({
                    url: ACTION_URL("AuthAdd_V", "Auth"),
                    title: "编辑认证",
                    width: 700,
                    height: 500,
                    //buttons: {
                    //    "button_save": {
                    //        type: 'primary',
                    //        text: '保存',
                    //        click: function () {
                    //            $.L.msgError(1)
                    //        }
                    //    },
                    "button_cancel": {
                        type: 'default',
                        text: '取消',
                        click: 'MODALMISS'
                    }
                });
            } else {
                $.L.msgError("未选择企业证书")
            }
        },


        Ajax_GetAuthlListByEID:function(){
        
            $.L.ajaxHandle({
                url: ACTION_URL("GetAuthListByEID", "Auth"),
                success: function (result) {

                    $("#AuthList").L_bindingDataList(result);

                }
            });
        
        
        
        
        },




        Ajax_GetBatchListByEID: function (EID) {

            $.L.ajaxHandle({
                url: ACTION_URL("GetProductBatchListByEID", "Product"),
                data: {EID:EID},
                success: function (result) {
                   
                    var html = "";
                    for (var i = 0; i < result.length; i++) {
                        html+="<option value='"+result[i].Id+"'>"+result[i].BatchName+"</option>"
                    }
                    $("#SBatchList").html(html);
                    var batchId = $("#batchId").val();
                    $("#SBatchList").val(batchId);
                }
            });

        },

      




        Ajax_GetModuleListByMaterialId: function (materialId) {

            $.L.ajaxHandle({
                url: ACTION_URL("GetModuleListByMaterialId", "OriginsMaterial"),
                data: { materialId: materialId },
                success: function (result) {
                    
                    $("#ModuleList").L_bindingDataList(result);
                }
            });
        },

        Ajax_GetMaterialListByEID:function(EID){
        
            $.L.ajaxHandle({
                url: ACTION_URL("GetMaterialListByEID", "OriginsMaterial"),
                data: { EID: EID },
                success: function (result) {
                   
                    $("#MaterialList").L_bindingDataList(result);
                }
            });
        
        },

        SelectModule: function (obj) {
            var selectModuleId = $(obj).attr("moduleId");
            $("#PageGoto").val(selectModuleId);
            _this.Dialog_SelectModuleListObj.close();
        },
        SelectMaterial: function (obj) {
            var selectMaterialId = $(obj).attr("materialId");
            $("#MaterialGoto").val(selectMaterialId);
            _this.Dialog_SelectMaterialListObj.close();
        },

        SelectAuth: function (obj) {
            var authId = $(obj).attr("Id");
            $("#AuthId").val(authId);
            //console.log($("#AuthId").val())
            _this.Dialog_SelectAuthListObj.close();
            $.L.msgSuccess("绑定认证成功");
            

        }
    })
})(jQuery);


//$(document).ready(function () {
//    var EID = $("#EID").val();

//    $.MGJ.DiamondEdition.Ajax_GetBatchListByEID(EID);



//});














